<?php

namespace App\Handler\Admin\System;

if (!defined('IN_PX'))
    exit;

use Phoenix\Routing\IHttpHandler;
use Phoenix\Support\MsgHelper;

class Search implements IHttpHandler {

    private function __Handler() {}

    private function __Inject($db, $session) {}

    public function processRequest(Array & $context)
    {
        if (is_array($_POST) && !empty($_POST)) {
            $_where = '0 = 0';
            $_bindParam = array();
            if (isset($_POST['title']) && $_POST['title'] != '') {
                $_where .= ' AND (a.`title` LIKE :title)';
                $_bindParam[':title'] = '%' . trim($_POST['title']) . '%';
            }
            $_table = '`#@__@archives` a, `#@__@archives_substance` ars';

            $this->rs = $this->db->table($_table)->where($_where)->bind($_bindParam)->findAll();

            echo(MsgHelper::json('SUCCESS',0,$this->rs));
        }
    }
}